# Strings

x = "CodingDojo"

puts x.length
puts x.class
puts x.capitalize # Capitalizes first letter, puts the rest in lowercase
puts x.upcase
puts x.downcase
puts x[2]
puts x.include? "dojo" # Case sensitive
puts x.include? "Dojo"
puts "This word has the word 'Dojo'" if x.include? "Dojo"
puts

x = "john, charles, matt, joe"
puts x.split(",").to_s
puts 

y = ""
puts "y is empty" if y.empty?
puts

# Arrays

a = ["Matz", "Guido", "Dojo", "Choi", "John"]
# Same as
a = %w{Matz Guido Dojo Choi John}

b = [5, 6, 9, 3, 1, 2, 4, 7, 8, 10]
c = ["Dojo", 9]

puts a[0] # Returns the first value of 0th index of the Arrays
puts a[1]

x = a + b
# Compare to
x = (a + b) - c

puts x.to_s

puts b.class
puts b.shuffle
puts b.shuffle.join(", ")

a.delete("Choi")
puts a

puts a.push("Heidi")
puts a.pop

puts "Length of a is #{a.length}"

puts a.reverse

# Range

x = (1..5)

puts "Class Name: #{x.class}"

puts "It does include 3!" if x.include? 3

puts "The last number of this range is " + x.last.to_s
puts "The maximum number of this range is " + x.max.to_s
puts "The minimum number of this range is " + x.min.to_s

y = ('a'..'z')
puts y.to_a.shuffle.to_s

# Hashes

x = {"first_name" => "Coding", "last_name" => "Dojo"}

puts x["first_name"] , x["last_name"]
puts "Your last name is Dojo" if x["last_name"].eql? "Dojo"

y = {:first_name => "Coding", :last_name => "Dojo"}
puts "Y is ", y
puts y[:first_name], y[:last_name]

puts "DELETING :first_name"
y.delete :first_name
puts "Y is now", y

if y.has_key?(:first_name)
	puts "Y has a key called :first_name"
else
	puts "Y does not have a key called :first_name"
end

if y.has_value? "Dojo"
	puts "Y has a value called Dojo"
else
	puts "Y does NOT have a value called Dojo"
end

# Blocks

# Unique to Ruby
# Inside curly braces

def test
	puts "You are in the method"
	yield
	puts "You are again back to the method"
	yield
end
test {puts "You are in the block"}

def test
	yield(5)
	puts "You are in the method test"
	yield(100)
end
test {|i| puts "You are in the block #{i}"}

def square(num)
	puts "num is #{num}"
	puts "yield(num) has a value of #{yield(num)}"
end

square(5) {|i| i = i}